package com.linwen.excise.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : linwen
 * @date : 11:34 下午 2020/10/30
 */
public class test {
    private static List<String> result;
    public static void main(String[] args) {
        int n = 3;
        System.out.println(function(n));
    }
    public static List<String> function(int n){
        result = new ArrayList<String>();
        String str = "";
        function2(0,0,n,str);
        return result;
    }

    private static void function2(int left, int right, int n, String str) {
        if(left==right&& left==n){
            result.add(str);
            return ;
        }
        if(left<n){
            function2(left+1,right,n,str+"(");
        }
        if(right<left){
            function2(left,right+1,n,str+")");
        }
    }
}
